package com.bw.zg3park2212.order

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.entity.OrderAddParam
import com.bw.base.mvvm.BaseActivity
import com.bw.zg3park2212.R
import com.bw.zg3park2212.databinding.ActivityOrderAddBinding
import dagger.hilt.android.AndroidEntryPoint
import java.text.SimpleDateFormat

@AndroidEntryPoint
@Route(path = "/app/OrderAddActivity")
class OrderAddActivity : BaseActivity<ActivityOrderAddBinding,OrderViewModel>() {
    override fun intitView() {
        binding.submit.setOnClickListener {
            var orderAddParam=OrderAddParam()
            orderAddParam.orderType=binding.orderType.text.toString()
            orderAddParam.content=binding.content.text.toString()
            orderAddParam.inspector=binding.inspector.text.toString()
            orderAddParam.address=binding.address.text.toString()
            orderAddParam.status="新建"
            orderAddParam.appointmentTime=SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis())
            viewmodel.getorderadd(orderAddParam)
        }
    }

    override fun intitData() {
        viewmodel.orderaddSuccse.observe(this){
            ToastUtils.showLong("添加成功")
            finish()
        }
    }

}